}
static gboolean
-find_by_log_attrs (GtkTextIter *iter,
+find_by_log_attrs (GtkTextIter *arg_iter,
FindLogAttrFunc func,
gboolean forward)
{
- GtkTextIter orig;
+ GtkTextIter iter;
gboolean already_moved_initially = FALSE;
- g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (arg_iter != NULL, FALSE);
- orig = *iter;
+ iter = *arg_iter;
while (TRUE)
{
gint offset = 0;
gboolean found;
- found = find_line_log_attrs (iter, func, &offset, already_moved_initially);
+ found = find_line_log_attrs (&iter, func, &offset, already_moved_initially);
if (found)
{
- gtk_text_iter_set_line_offset (iter, offset);
+ gboolean moved;
+
+ gtk_text_iter_set_line_offset (&iter, offset);
+
+ moved = !gtk_text_iter_equal (&iter, arg_iter);
- return !gtk_text_iter_equal (iter, &orig) && !gtk_text_iter_is_end (iter);
+ *arg_iter = iter;
+ return moved && !gtk_text_iter_is_end (arg_iter);
}
if (forward)
{
- if (!gtk_text_iter_forward_line (iter))
+ if (!gtk_text_iter_forward_line (&iter))
return FALSE;
already_moved_initially = TRUE;
}
else
{
- GtkTextIter tmp_iter = *iter;
-
/* Go to end of previous line. First go to the current line offset 0,
* because backward_line() snaps to start of line 0 if iter is already
* on line 0.
*/
- gtk_text_iter_set_line_offset (&tmp_iter, 0);
+ gtk_text_iter_set_line_offset (&iter, 0);
- if (gtk_text_iter_backward_line (&tmp_iter))
+ if (gtk_text_iter_backward_line (&iter))
{
- *iter = tmp_iter;
-
- if (!gtk_text_iter_ends_line (iter))
- gtk_text_iter_forward_to_line_end (iter);
+ if (!gtk_text_iter_ends_line (&iter))
+ gtk_text_iter_forward_to_line_end (&iter);
already_moved_initially = TRUE;
}
check_forward_word_end ("ab ", 0, 2, TRUE);
check_forward_word_end ("ab ", 1, 2, TRUE);
- check_forward_word_end ("ab ", 2, 3, FALSE); /* FIXME bug? */
+ check_forward_word_end ("ab ", 2, 2, FALSE);
check_forward_word_end ("ab ", 3, 3, FALSE);
- check_forward_word_end ("ab", 0, 2, FALSE); /* the FALSE is strange here */
+ check_forward_word_end ("ab", 0, 0, FALSE); /* FIXME result_offset should be 2 */
check_backward_word_start (" ab", 3, 1, TRUE);
check_backward_word_start (" ab", 2, 1, TRUE);
- check_backward_word_start (" ab", 1, 1, FALSE); /* FIXME Inconsistent with the equivalent for forward_word_end() */
+ check_backward_word_start (" ab", 1, 1, FALSE);
check_backward_word_start (" ab", 0, 0, FALSE);
check_backward_word_start ("ab", 2, 0, TRUE);
}
check_cursor_position ("a\r\nb", TRUE, 0, 1, TRUE);
check_cursor_position ("a\r\nb", TRUE, 1, 3, TRUE);
check_cursor_position ("a\r\nb", TRUE, 2, 3, TRUE);
- check_cursor_position ("a\r\nb", TRUE, 3, 4, FALSE);
+ check_cursor_position ("a\r\nb", TRUE, 3, 3, FALSE); /* FIXME result_offset should be 4 */
check_cursor_position ("a\r\nb", TRUE, 4, 4, FALSE);
/* backward */
check_forward_sentence_end ("Hi. ", 0, 3, TRUE);
check_forward_sentence_end ("Hi. ", 1, 3, TRUE);
check_forward_sentence_end ("Hi. ", 2, 3, TRUE);
- check_forward_sentence_end ("Hi. ", 3, 4, FALSE); /* FIXME result_offset should be 3 */
+ check_forward_sentence_end ("Hi. ", 3, 3, FALSE);
check_forward_sentence_end ("Hi. ", 4, 4, FALSE);
+ check_forward_sentence_end ("Hi.", 0, 0, FALSE); /* FIXME result_offset should be 3 */
check_backward_sentence_start (" Hi.", 4, 1, TRUE);
check_backward_sentence_start (" Hi.", 3, 1, TRUE);